<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>首页</title>
    <link rel="stylesheet" href="bootstrap-4.5.3/css/bootstrap.css" />
    <link rel="stylesheet" href="css/common.css">
</head>

<body>
    <!-- 导航条 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <a class="navbar-brand" href="#">
            <img src="./images/a.jpg" style="height: 30px" class="img-fluid" alt="" />
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar">
            <!-- 三个横杠 -->
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbar">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active text-light">xxxx 管理系统</li>
            </ul>
            <div class="my-2 my-lg-0">
                <img src="./images/a.jpg" style="height: 30px; width: 30px; border-radius: 50%" class="img-fluid"
                    alt="" />
                <span class="text-light"> 欢迎您:
                    <span id="curNameNode"></span>

                </span>
                <button id="logoutNode" class="btn btn-primary text-light btn-sm">退出</button>
            </div>
        </div>
    </nav>
    <!-- 内容区 -->
    <div class="container-fluid ">
        <div class="row">
            <div class="col-3">
                <div class="my-menu">
                    <ul class="list-group">
                        <li class="list-group-item active">用户管理</li>
                        <li class="list-group-item">
                            <a href="./pages/student.html" target="myfram">学生管理</a>
                        </li>
                        <li class="list-group-item">
                            <a href="./pages/online.html" target="myfram">在线登录管理</a>
                        </li>
                        <li class="list-group-item">菜单管理</li>
                    </ul>
                </div>
                <div class="my-menu">
                    <ul class="list-group">
                        <li class="list-group-item active">商品管理</li>
                        <li class="list-group-item">商品管理</li>
                        <li class="list-group-item">订单管理</li>
                    </ul>
                </div>

            </div>
            <div class="col-9">
                <iframe src="./pages/student.html" name="myfram"
                    style="border: none;width: 100%; height: 90vh;"></iframe>
            </div>
        </div>
    </div>

   



    <!-- 底部 -->
    <!-- 导航条 -->
    <nav class="navbar  fixed-bottom navbar-expand-lg navbar-dark bg-dark" style="text-align: center;">

        <span class="text-light"> 版权归xxx所有</span>

    </nav>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.js"></script>
   
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="./bootstrap-4.5.3/js/bootstrap.js"></script>
    <script src="./utils/tools.js"></script>

    <script>
        init();
        /**
         * 发送ajax 请求用户信息
         */
        function init() {
            var user = sessionStorage.getItem("user")
            if(!user) {
                alert("暂未登录！")
                location.href="./login.html"
                return;
            }
            var userObj = JSON.parse(user)
            curNameNode.innerText = userObj.username

            // 发送ajax请求  
            // $.ajax({
            //     url: obj.baseUrl + "/user?method=current",
            //     success: function (result) {
            //         // console.log(result);
            //         if (result.status == 200) {
            //             var user = result.data
            //             console.log(user);
            //             curNameNode.innerText = user.username
                        
            //         } else {
            //             alert(result.msg);
            //             location.href="./login.html"
            //         }
            //     }
            // })

        }

        logoutNode.onclick = function() {
            // 清空sessionStorage
            sessionStorage.removeItem("user");
            location.href="./login.html"
        }
    </script>
</body>

</html>